package com.hot100;

public class Solution338 {
    public int[] countBits(int n) {
        int[] res = new int[n + 1];
        res[0] = 0;
        if (n == 0) return res;
        for (int i = 1; i <= n; i++) {
            if (i%2==1) res[i] = res[i-1]+1;
            else res[i] = res[i/2];
        }
        return res;
    }
}
